package com.jyserver.common.utils;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Collection;
import java.util.Map;

public class HelpUtils extends Replaces {
    /**
     * @Description:常见辅助类
     * @author ChenYM
     * @date 2018/7/3 0003 下午 22:51
     */
    private static Log log = LogFactory.getLog(HelpUtils.class);

    public static boolean isEmpty(Object Obj) {
        /**
         * @Description:判断对象是否为空
         * @param Obj
         * @author ChenYM
         * @date 2018/7/3 0003 下午 22:52
         * @Return boolean
         */
        if (Obj == null)
            return true;
        if (Obj == "")
            return true;
        if (Obj instanceof String) {
            if (((String) Obj).length() == 0) {
                return true;
            }
        } else if (Obj instanceof Collection) {
            if (((Collection) Obj).size() == 0) {
                return true;
            }
        } else if (Obj instanceof Map) {
            if (((Map) Obj).size() == 0) {
                return true;
            }
        }
        return false;
    }

    public static boolean isNotEmpty(Object Obj) {
        /**
         * @Description:检查对象是否不为空
         * @param Obj
         * @author ChenYM
         * @date 2018/7/3 0003 下午 22:58
         * @Return boolean
         */
        if (Obj == null)
            return false;
        if (Obj == "")
            return false;
        if (Obj instanceof String) {
            if (((String) Obj).length() == 0) {
                return false;
            }
        } else if (Obj instanceof Collection) {
            if (((Collection) Obj).size() == 0) {
                return false;
            }
        } else if (Obj instanceof Map) {
            if (((Map) Obj).size() == 0) {
                return false;
            }
        }
        return true;
    }
}
